<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>鑫多多</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<script src="../js/common.js"></script>
		<link rel="stylesheet" href="../css/mui.min.css">
		<style>
			html,
			body {
				background-color: #efeff4;
			}
		</style>
	</head>

	<body>
		<!--<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">商品展示</h1>
		</header>-->
		<nav class="mui-bar mui-bar-tab" id="nav">
			<a id="index" class="mui-tab-item mui-active" href="goods_index.html">
				<span class="mui-icon mui-icon-home"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a id="msg" class="mui-tab-item" href="message-list.html">
				<span class="mui-icon mui-icon-email" id="msgCount"></span>
				<span class="mui-tab-label">消息</span> 
			</a>
			<a id="myOwn" class="mui-tab-item" href="myOwn.html">
				<span class="mui-icon mui-icon-contact" id="qfCount"></span>
				<span class="mui-tab-label">我的</span>
			</a>
			<a id="setting" class="mui-tab-item" href="setting.html">
				<span class="mui-icon mui-icon-gear"></span>
				<span class="mui-tab-label">设置</span>
			</a>
		</nav>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" charset="utf-8"> 
			 //mui初始化
			//mui.init();
			//var subpages = ['goodsList.html', 'message-list.html', 'myOwn.html', 'setting.html'];
			 mui.init({  
                    subpages:[//先加载首页  
                        {  
                          url:'goods_index.html',  
                          id:'index',  
                          styles:{  
                             top:'0px',  
                                bottom:'50px'  
                          }  
                        }
                       /* ,{
                          url:'message-list.html',  
                          id:'msg',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        },  
                        {  
                          url:'myOwn.html',  
                          id:'myOwn',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        },  
                        {  
                          url:'setting.html',  
                          id:'setting',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        }  */
                    ],  
                    preloadPages:[//缓存其他页面  
                        {  
                          url:'baidushangqiao.html',  
                          id:'msg',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        },  
                        {  
                          url:'myOwn.html',
                          id:'myOwn',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        },  
                        {  
                          url:'setting.html',  
                          id:'setting',  
                          styles:{  
                             top:'0px',  
                            bottom:'50px'  
                          }  
                        }  
                    ]  
                      
                }); 
                
              
            mui.plusReady(function(){
            	/*function closeMsgIntevel(){
					var target = plus.webview.getWebviewById('msg');
					target.evalJS("deleteMsgTime()");//关闭消息请求定时器
				}*/
                // 获取所有Webview窗口  
                var winAll=plus.webview.all();//获取所有窗体
                //console.log(JSON.stringify(winAll))   
                mui("#nav").on("tap","#index",function(){//点击触发   
                    changeCheckPage("index");
                    getQfCount();
                })  
                mui("#nav").on("tap","#msg",function(){//点击触发  
                	changeCheckPage("msg");
                	getQfCount();
                })  
                mui("#nav").on("tap","#myOwn",function(){//点击触发  
                	changeCheckPage("myOwn");
                	getQfCount();
                })  
                mui("#nav").on("tap","#setting",function(){//点击触发  
                	changeCheckPage("setting");
                	getQfCount();
                })  
                var ifFirst=true;
                var msgIfFirst=true;
                var  changeCheckPage=function(tag){
                	var strs=["index","msg","myOwn","setting"];
                	for(var i=0;i<strs.length;i++){
                		if(tag==strs[i]){
                			if(tag=="msg"&&!ifFirst){
                				
                			}else{
                				ifFirst=false;	
                				
                			}
                			if(tag=="msg"&&msgIfFirst){
                				var target = plus.webview.getWebviewById('msg');
//								target.evalJS("openTalkPage()");//修改底部角标数据
								msgIfFirst=false;
                			}
                			if(tag!="msg"){
								closeMsgIntevel();
                			}
                			if(tag=="myOwn"){
                				plus.webview.getWebviewById("myOwn").reload(true);//重新加载
                			}
                			plus.webview.getWebviewById(strs[i]).show();
                		}else{
                			plus.webview.getWebviewById(strs[i]).hide();
                		}
                	}
                }
            }); 
//          var url=baseUrl+"/mapi/mmsg/talk/notRead";
//			function changeTalkCount() {
//				mui.ajax(url,{
//				    dataType:'json',//服务器返回json格式数据
//				    type:'get',//HTTP请求类型	
//				    timeout:10000,//超时时间设置为10秒；
//				    headers:{'Content-Type':'application/json'},                  
//				    success:function(data){
//				    	if(data.data!=null&&data.data>0){
//				    		document.getElementById("msgCount").innerHTML="<span class='mui-badge' >"+data.data+"</span>";
//				    	}else{
//				    		document.getElementById("msgCount").innerHTML="";
//				    	}
//				    },
//				    error:error
//				});
//			}
//			changeTalkCount();
			var url=baseUrl+"/mapi/msgGroup/getNoReadQF";
			function getQfCount() {
				mui.ajax(url,{
				    dataType:'json',//服务器返回json格式数据
				    type:'get',//HTTP请求类型	
				    timeout:10000,//超时时间设置为10秒；
				    headers:{'Content-Type':'application/json'},                  
				    success:function(data){
				    	if(data.data!=null&&data.data>0){
				    		document.getElementById("qfCount").innerHTML="<span class='mui-badge' >"+data.data+"</span>";
				    	}else{
				    		document.getElementById("qfCount").innerHTML="";
				    	}
				    },
				    error:error
				});
			}
//			setTimeout(getQfCount(),2000);
			getQfCount();
		</script>
	</body>

</html>